home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 5 Developer's Kit / vb5 dev kit.iso / dev / jdsaver / mainform.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-09-13  |  4.0 KB  |  112 lines

  1. VERSION 4.00
  2. Begin VB.Form MainForm 
  3.    AutoRedraw      =   -1  'True
  4.    BorderStyle     =   0  'None
  5.    Caption         =   "Screen Saver Main Form"
  6.    ClientHeight    =   6552
  7.    ClientLeft      =   3288
  8.    ClientTop       =   1812
  9.    ClientWidth     =   5772
  10.    Height          =   6876
  11.    Left            =   3240
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   6552
  16.    ScaleWidth      =   5772
  17.    ShowInTaskbar   =   0   'False
  18.    Top             =   1536
  19.    Width           =   5868
  20.    Begin VB.Timer Timer1 
  21.       Interval        =   400
  22.       Left            =   1368
  23.       Top             =   744
  24.    End
  25. Attribute VB_Name = "MainForm"
  26. Attribute VB_Creatable = False
  27. Attribute VB_Exposed = False
  28. 'For information about this program see the declarations
  29. 'section of the JDSaver.BAS module.
  30. 'This form is the screen saver output, and will cover the screen.
  31. 'It is called from Sub Main when the program is started with
  32. 'the /s command parameter
  33. Option Explicit
  34. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  35.     'Immediately end when any key is pressed
  36.     Unload Me
  37. End Sub
  38. Private Sub Form_Load()
  39.     'Make the screen saver a TOPMOST window
  40.     tempLong = SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
  41.     'Make the form exactly cover the screen
  42.     Move 0, 0, Screen.Width, Screen.Height
  43.     'Find out from the System Registry if the user
  44.     'has enabled password protection for screen savers.
  45.     PWProtect = Val(RegGetValue(HKEY_CURRENT_USER, "Control Panel\Desktop", "ScreenSaveUsePassword"))
  46.     'Haven't found a way for a VB program to use the System
  47.     'Screen Saver Password, so a separate one is maintained for
  48.     'this program
  49.     Password = GetSetting("Samples", "JD Screen Saver", "Password")
  50.     'Copy a clone of the desktop onto the form, to
  51.     'serve as a background for the circle painting
  52.     CopyScreen Me
  53.     'Make the cursor disappear
  54.     Do
  55.     Loop Until ShowCursor(False) < -5
  56. End Sub
  57. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
  58.     'Immediately end on any mouse button being pressed
  59.     Unload Me
  60. End Sub
  61. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
  62.     Static TimeDelay&
  63.     MouseMoves = MouseMoves + 1
  64.     'There will probably be a MouseMove event or two at
  65.     'startup that need to be eaten.
  66.     'Change value for more or less mouse sensitivity
  67.     'If you want to get fancy, add a scroll bar on the
  68.     'configuration form to let the user select sensitivity.
  69.     If MouseMoves = 4 Then
  70.          Unload Me
  71.     End If
  72.     'MouseMove events are cumulative, so over time there
  73.     'might be "mouse creep."  Reset the counter if more
  74.     'than 10 seconds have elapsed since mouse movement
  75.     'began.
  76.     If TimeDelay = 0 Then
  77.         TimeDelay = Timer
  78.     ElseIf Timer - TimeDelay > 10 Then
  79.         TimeDelay = 0
  80.         MouseMoves = 0
  81.     End If
  82. End Sub
  83. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  84.     'Before we exit, we need to input a password if
  85.     'password protection is enabled and a password has
  86.     'been set by the user.
  87.     If Password <> "" And PWProtect Then
  88.         'We need a cursor so that the user can move around
  89.         'the password form
  90.         Do
  91.         Loop Until ShowCursor(True) > 5
  92.         PassCheck.Show 1
  93.         'PassChck is a Public flag set by the
  94.         'PassCheck module.
  95.         If PassChck = False Then
  96.              'Make the cursor disappear again
  97.             Do
  98.             Loop Until ShowCursor(False) < -5
  99.             Cancel = True
  100.         End If
  101.     End If
  102. End Sub
  103. Private Sub Form_Unload(Cancel As Integer)
  104.     'Restore the mouse cursor
  105.     Do
  106.     Loop Until ShowCursor(True) > 5
  107. End Sub
  108. Private Sub Timer1_Timer()
  109.     'Continue to make circles
  110.     Draw Me
  111. End Sub
  112.